Skip to content

[python] Add requests as dependency#7960

Merged
XiaoHongbo-Hope merged 1 commit into
apache:masterfrom
aisk:requests
May 31, 2026
Merged

[python] Add requests as dependency#7960
XiaoHongbo-Hope merged 1 commit into
apache:masterfrom
aisk:requests

Conversation

@aisk

@aisk aisk commented May 25, 2026

Copy link
Copy Markdown
Contributor

Purpose

Currently requests is required to using Paimon, otherwise it will raise error when importing paimon on current main branch:

>>> import pypaimon
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    import pypaimon
  File "/home/asaka/paimon/paimon-python/pypaimon/__init__.py", line 26, in <module>
    from pypaimon.catalog.catalog_factory import CatalogFactory
  File "/home/asaka/paimon/paimon-python/pypaimon/catalog/catalog_factory.py", line 23, in <module>
    from pypaimon.catalog.filesystem_catalog import FileSystemCatalog
  File "/home/asaka/paimon/paimon-python/pypaimon/catalog/filesystem_catalog.py", line 45, in <module>
    from pypaimon.table.file_store_table import FileStoreTable
  File "/home/asaka/paimon/paimon-python/pypaimon/table/file_store_table.py", line 25, in <module>
    from pypaimon.read.read_builder import ReadBuilder
  File "/home/asaka/paimon/paimon-python/pypaimon/read/read_builder.py", line 20, in <module>
    from pypaimon.common.predicate import Predicate
  File "/home/asaka/paimon/paimon-python/pypaimon/common/predicate.py", line 29, in <module>
    from pypaimon.manifest.schema.simple_stats import SimpleStats
  File "/home/asaka/paimon/paimon-python/pypaimon/manifest/schema/simple_stats.py", line 22, in <module>
    from pypaimon.table.row.generic_row import GenericRow
  File "/home/asaka/paimon/paimon-python/pypaimon/table/row/generic_row.py", line 28, in <module>
    from pypaimon.table.row.blob import BlobData
  File "/home/asaka/paimon/paimon-python/pypaimon/table/row/blob.py", line 24, in <module>
    from pypaimon.common.uri_reader import UriReader, FileUriReader
  File "/home/asaka/paimon/paimon-python/pypaimon/common/uri_reader.py", line 23, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

With the latest release of pypaimon on PyPI, we can import pypaimon, but import CatalogFactory from pypaimon will raise the same error.

Adding requests to requirements.txt can resolve this error. requests 2.21.0 was released in 2018, I think it's old enough to be used as the minimum version range.

Tests

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix itself is correct — requests is imported unconditionally by uri_reader.py so it must be declared as a dependency.

However, the file being modified is dev/requirements.txt. Is this actually the runtime dependency spec that PyPI packaging picks up? I'd expect it to be in setup.py, pyproject.toml, or a dedicated requirements.txt at the package root (not under dev/). If this is only used for development/CI environments, the import-time failure on the released wheel would remain unsolved.

Could you check whether this is the correct file for declaring runtime dependencies? If there's a separate packaging config (e.g., pyproject.toml or setup.cfg), requests should be added there as well.

@aisk

aisk commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Currently, pypaimon is using a legacy setup.py and reading dev/requirements.txt as dependencies in it, so this PR could resolve the issue:

def read_requirements():
"""Read requirements from dev/requirements.txt file."""
requirements_path = os.path.join(os.path.dirname(__file__), 'dev', 'requirements.txt')
requirements = []
if os.path.exists(requirements_path):
with open(requirements_path, 'r', encoding='utf-8') as f:
for line in f:
line = line.strip()
# Skip empty lines and comments
if line and not line.startswith('#'):
requirements.append(line)
return requirements

I think we should upgrade to a modern way of managing dependencies (e.g., using pyproject.toml with or without uv), but I think that could happen in another PR.

@XiaoHongbo-Hope

Copy link
Copy Markdown
Contributor

+1

@XiaoHongbo-Hope XiaoHongbo-Hope merged commit dd79ff7 into apache:master May 31, 2026
6 checks passed
@aisk aisk deleted the requests branch May 31, 2026 13:48
@XiaoHongbo-Hope

Copy link
Copy Markdown
Contributor

Thanks for raising and fixing the issue. I will include this fix in 1.4.2.

XiaoHongbo-Hope pushed a commit that referenced this pull request Jun 3, 2026
### Purpose

Currently requests is required to using Paimon, otherwise it will raise
error when importing `paimon` on current main branch:

```
>>> import pypaimon
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    import pypaimon
  File "/home/asaka/paimon/paimon-python/pypaimon/__init__.py", line 26, in <module>
    from pypaimon.catalog.catalog_factory import CatalogFactory
  File "/home/asaka/paimon/paimon-python/pypaimon/catalog/catalog_factory.py", line 23, in <module>
    from pypaimon.catalog.filesystem_catalog import FileSystemCatalog
  File "/home/asaka/paimon/paimon-python/pypaimon/catalog/filesystem_catalog.py", line 45, in <module>
    from pypaimon.table.file_store_table import FileStoreTable
  File "/home/asaka/paimon/paimon-python/pypaimon/table/file_store_table.py", line 25, in <module>
    from pypaimon.read.read_builder import ReadBuilder
  File "/home/asaka/paimon/paimon-python/pypaimon/read/read_builder.py", line 20, in <module>
    from pypaimon.common.predicate import Predicate
  File "/home/asaka/paimon/paimon-python/pypaimon/common/predicate.py", line 29, in <module>
    from pypaimon.manifest.schema.simple_stats import SimpleStats
  File "/home/asaka/paimon/paimon-python/pypaimon/manifest/schema/simple_stats.py", line 22, in <module>
    from pypaimon.table.row.generic_row import GenericRow
  File "/home/asaka/paimon/paimon-python/pypaimon/table/row/generic_row.py", line 28, in <module>
    from pypaimon.table.row.blob import BlobData
  File "/home/asaka/paimon/paimon-python/pypaimon/table/row/blob.py", line 24, in <module>
    from pypaimon.common.uri_reader import UriReader, FileUriReader
  File "/home/asaka/paimon/paimon-python/pypaimon/common/uri_reader.py", line 23, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'
```

With the latest release of `pypaimon` on PyPI, we can import `pypaimon`,
but `import CatalogFactory from pypaimon` will raise the same error.

Adding `requests` to `requirements.txt` can resolve this error.
`requests 2.21.0` was released in 2018, I think it's old enough to be
used as the minimum version range.

### Tests

(cherry picked from commit dd79ff7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants